package oocl.eshop.util.regular;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class DataMatching {

	public static boolean isNum(String s) {
		Pattern pattern = Pattern.compile("^[0-9]{1,5}$");
		Matcher matcher = pattern.matcher(s);
		if (matcher.find()) {
			return true;
		}
		return false;
	}

	// 电话正则表达式
	public static boolean isTel(String s) {
		Pattern pattern = Pattern.compile("^(\\d){11}$");
		Matcher matcher = pattern.matcher(s);
		if (matcher.find())
			return true;
		return false;
	}

	// 身份证正则表达式
	public static boolean isIdCard(String s) {
		Pattern pattern = Pattern.compile("^(\\d){18}$");
		Matcher matcher = pattern.matcher(s);
		if (matcher.find())
			return true;
		return false;
	}

	// 匹配价钱
	public static boolean isPrice(String s) {
		Pattern pattern = Pattern.compile("^\\d{1,5}+(\\.\\d{1,2})?$");
		Matcher matcher = pattern.matcher(s);
		if (matcher.find())
			return true;
		return false;
	}

	// 名字正则表达式
	public static boolean isName(String s) {
		Pattern pattern = Pattern.compile("^[a-zA-Z0-9]{3,20}$");
		Matcher matcher = pattern.matcher(s);
		if (matcher.find()) {
			return true;
		}
		return false;
	}

	// 密码正则表达式
	public static boolean isPassword(String s) {
		Pattern pattern = Pattern.compile("^[a-zA-Z0-9]{6,30}$");
		Matcher matcher = pattern.matcher(s);
		if (matcher.find()) {
			return true;
		}
		return false;
	}
	
	

}
